package sechomework;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class SecCollection {
    public static void main(String[] args) {


        Collection<String> c=new ArrayList<>();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        System.out.println("c:"+c);
        System.out.println("长度:"+c.size());
        System.out.println("是否为空集:"+c.isEmpty());
        System.out.println(c.contains("two"));
        //c.clear();
        //System.out.println("c:"+c);
        //c.remove("one");
        //System.out.println("c:"+c);

        Collection<String> c1=new ArrayList<>();
        c1.add("two");
        c1.add("four");
        c1.add("six");
        c1.add("eight");
        System.out.println("c1:"+c1);
        //c1.addAll(c);
        //System.out.println("c1:"+c1);
        System.out.println(c.containsAll(c1));
        //c1.retainAll(c);//取交集
        //System.out.println("c1:"+c1);

        //c.removeAll(c1);
        //System.out.println("c:"+c);

        Iterator<String> it=c.iterator();
        while(it.hasNext()){
            System.out.println(it.next());
        }

        String[] arr=c.toArray(new String[0]);
        for(String str: arr){
            System.out.println(str);
        }
    }
}
